package cn.edu.hunau.oop.day03.shape;

import org.junit.Test;

/**
 * @author hb
 * @date 2025-08-05 16:57:43
 */
public class TestShape {

    @Test
    public void test03(){
        Shape [] arr=new Shape[5];
        arr[0]=new Circle(0,0,2);
        arr[1]=new Rectangle(0,0,2,2);
        arr[2]=new Rectangle(0,0,2,2);
        arr[3]=new Rectangle(0,0,2,2);
        arr[4]=new Circle(0,0,2);
        //统计shape中圆和矩形的数量.
        for(Shape data:arr){
            //判断data的实际运行时类型是否为Circle或者Circle的子类
           if(data instanceof Circle){
               System.out.println("圆");
           }
        }
    }

    @Test
    public void test02(){
         Shape s1=new Circle(0,0,2);
         if(s1 instanceof Circle){
             Circle c1=(Circle)s1;
             System.out.println(c1.area());
         }


         Shape s2=new Rectangle(0,0,2,2);
         if(s2 instanceof Circle){
             Circle r1=(Circle)s2;
         }

    }

    @Test
    public void test01(){
        Shape s1=new Circle(0,0,2);
        System.out.println(s1.area());
        System.out.println(s1.container(1,1));

        Shape s2=new Rectangle(0,0,2,2);
        System.out.println(s2.area());
    }
}
